const express=require("express");
var router=express.Router();
var pool=require("../pool");
router.get("/",(req,res)=>{
    var kw=req.query.kw;
    console.log(kw);
    var sql=`select * from mx_book where title like '%${kw}%' or author like '%${kw}%'`;
    pool.query(sql,[],(err,result)=>{
      if(err){
        console.log(err);
      }
      res.send(result);
      console.log(result);
    })
  })
router.get("/tit",(req,res)=>{
  var title=req.query.title;
  var sql="select * from mx_book where title=?";
  pool.query(sql,[title],(err,result)=>{
    if(err) throw err;
    res.send(result)
  })
})
module.exports=router;